package com.example.app.ui.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.app.viewmodel.TaskViewModel

@Composable
fun CircleRing(boxWidth: Int, vm: TaskViewModel = viewModel()) {
    val strokeWidth = 30f
    Canvas(modifier = Modifier.size(boxWidth.dp)) {
//        rotate(180f){
        drawArc(
            color = Color(0, 0, 0, 15),
            startAngle = 160f,
            sweepAngle = 220f,
            useCenter = false,
            style = Stroke(strokeWidth, cap = StrokeCap.Round)
        )
        drawArc(
            color = Color.White,
            startAngle = 160f,
            sweepAngle = vm.pointOfYearPercent,
            useCenter = false,
            style = Stroke(strokeWidth, cap = StrokeCap.Round)
        )
//        }
    }
}


@Preview(showBackground = true)
@Composable
fun CircleRingPreview() {
    CircleRing(150)
}